<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <search :config='searchConfig' @getHeight='getHeight' @search='search' />
    <!-- table区域-begin -->
    <div class='page_table'>
      <vxe-grid
        ref='xGrid'
        v-bind='vexConfig'
        :align='left'
        :border='true'
        :checkbox-config="checkboxConfig"
        :columns='columns'
        :data='dataSource'
        :height='pageHeight-seachHeight-94'
        :loading='loading'
        :resizable='true'
        :showOverflow='true'
        :toolbar-config="tableToolbar"
        size='mini'
        @checkbox-change='selectChangeEvent'
        @checkbox-all="selectChangeEvent"
      >
        <!-- 按钮区域 -->
        <template #toolbar_buttons>
          <div class='table-operator'>
            <a-button type="primary" @click="handleAdd">新增</a-button>
            <a-button type="primary" @click="batchDel">删除</a-button>
          </div>
        </template>
        <template #detail='{ row }'>
          <a @click="handleDetail(row)">{{ row.actCode }}</a>
        </template>
        <template  #action='{ row,rowIndex }'>
          <a v-has="'getGoodsAdress:update'" @click='handleEdit(row)'>编辑</a>
<!--          <a-divider type='vertical' />-->
<!--          <a-dropdown>-->
<!--            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>-->
<!--            <a-menu slot="overlay">-->
<!--              <a-menu-item>-->
<!--                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">-->
<!--                  <a>删除</a>-->
<!--                </a-popconfirm>-->
<!--              </a-menu-item>-->
<!--            </a-menu>-->
<!--          </a-dropdown>-->
        </template>
        <template #actFileUrl='{ row }'>
          <viewer :images='row.actFileUrl'>
            <a-avatar :src='row.actFileUrl' icon='user' shape='square' size='small'/>
          </viewer>
        </template>
        <template #update='{ row }'>
          <a-switch :checked='row.status' size='small' @change='handleStatus(row,$event)' />
        </template>
        <template #haveScope='{ row }'>
          {{ row.haveScope == 1 ? '有' : '无' }}
        </template>
        <template #pager>
          <vxe-pager
            :currentPage.sync='ipagination.current'
            :layouts="['Total', 'PrevJump', 'PrevPage', 'Number', 'NextPage', 'NextJump','Sizes', 'FullJump']"
            :page-size.sync='ipagination.pageSize'
            :pageSizes='ipagination.pageSizeOptions'
            :total='ipagination.total'
            @page-change='handlePageChange'>
          </vxe-pager>
        </template>
      </vxe-grid>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <tpm-act-special-modal ref="modalForm" @ok="modalFormOk"></tpm-act-special-modal>
  </a-card>
</template>

<script>
import TpmActSpecialModal from './modules/TpmActSpecialModal'
import {PageListMixin} from '@/mixins/PageListMixin'

export default {
  name: 'TpmActSpecialList',
  mixins: [PageListMixin],
  components: {
    TpmActSpecialModal
  },
  data() {
    return {
      message: '',
      imgIndex:0,
      showImg: false,
      imgSrc: [],
      description: '专项活动管理页面',
      // 查询区域
      searchConfig: [
        {
          type: 'input',
          name: 'actCode',
          placeholder: '活动编号'
        },
        {
          type: 'input',
          name: 'actName',
          placeholder: '活动名称'
        },
        {
          type: 'date',
          name: 'actStart',
          placeholder: '活动时间'
        },
        // {
        //   type: 'date',
        //   name: 'createTime',
        //   placeholder: '创建时间'
        // },
        {
          type: 'date-range', //范围选择
          range: ['startCreateTime', 'endCreateTime'],
          name: 'range',
          format: 'YYYY-MM-DD',
          placeholder: ['创建开始时间', '创建结束时间']
        }
      ],
      // 表头
      columns: [
        {
          width:50,
          type:'checkbox',
        },
        {
          title: '活动编号',
          minWidth:'80',
          field: 'actCode',
          slots: {default: 'detail'}
        },
        {
          title: '活动名称',
          minWidth:'80',
          field: 'actName'
        },
        {
          title: '活动开始时间',
          minWidth:'120',
          field: 'actStart'
        },
        {
          title: '活动结束时间',
          minWidth:'120',
          field: 'actEnd'
        },
        {
          title: '活动内容',
          minWidth:'80',
          field: 'actContent',
          scopedSlots: { customRender: 'titleShow' },
        },
        {
          title: '执行要求',
          minWidth:'80',
          field: 'actExecNeeds',
          scopedSlots: { customRender: 'execShow' },

        },
        // {
        //   title: '采集项目',
        //   minWidth:'80',
        //   field: 'actCollectionsName'
        // },
        {
          title: '活动范围',
          minWidth:'120',
          field: 'haveScope',
          slots: {default:'haveScope'}
        },
        {
          title: '创建人',
          minWidth:'80',
          field: 'createName',
        },
        {
          title: '创建时间',
          minWidth:'80',
          field: 'createTime',
        },
        {
          title: '更新人',
          minWidth: 80,
          field: 'updateName'
        },
        {
          title: '更新时间',
          minWidth: 80,
          field: 'updateTime'
        },
        {
          title: '操作',
          field: 'action',
          width:'80',
          slots: { default: 'action' }
        },
      ],
      isorter: {
        permflag: 'active_list_page_impl'
      },
      url: {
        list: window._CONFIG['domianSfaURL']+'/act/tpmActSpecial/findPageList',
        detail: window._CONFIG['domianSfaURL'] + '/act/tpmActSpecial/getInfo',
        delete:  window._CONFIG['domianSfaURL']+'/act/tpmActSpecial/delete',
        deleteBatch:  window._CONFIG['domianSfaURL']+'/act/tpmActSpecial/deleteBatch',
        exportXlsUrl: 'act/tpmActSpecial/exportXls',
      }
    }
  },
  computed: {
    importExcelUrl: function() {
      return `${window._CONFIG['domianTpmURL']}/${this.url.importExcelUrl}`
    }
  },
  methods: {

  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
/*动画*/
.fade-enter-active,
.fade-leave-active {
  transition: all .2s linear;
  transform: translate3D(0, 0, 0);
}

.fade-enter,
.fade-leave-active {
  transform: translate3D(100%, 0, 0);
}

/* bigimg */

.img-view {
  position: relative;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

/*遮罩层样式*/
.img-view .img-layer {
  position: fixed;
  z-index: 99998;
  top: 0;
  left: 0;
  background: rgba(0, 0, 0, 0.7);
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/*不限制图片大小，实现居中*/
.img-view .img img {
  position: absolute;
  min-width: 50%;
  max-width: 50%;
  display: block;
  left: 0;
  right: 0;
  margin: auto;
  z-index: 99999;
}
.left {
  position: absolute;
  min-width: 5%;
  max-width: 5%;
  display: block;
  left: 0px;
  margin: auto;
  z-index: 99999;
  top: 110px;
}
.right {
  position: absolute;
  min-width: 5%;
  max-width: 5%;
  display: block;
  right: 0px;top: 110px;
  margin: auto;
  z-index: 99999;
}
.shenpito {
  color: #434e59;
}
.shenpion{
  color: #2eabff;
}
.smileDark {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  width: 180px;
}
</style>